package com.common.model.util;

import java.util.HashMap;

public class AjaxResult extends HashMap<String,Object> {

    private static final long serialVersionUID = 1L;

    public static AjaxResult success(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",200);
        ajaxResult.put("msg",msg);
        return ajaxResult;
    }

    public static AjaxResult error(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",500);
        ajaxResult.put("msg",msg);
        return ajaxResult;
    }

    public static AjaxResult error(int code,String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",code);
        ajaxResult.put("msg",msg);
        return ajaxResult;
    }

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",200);
        return ajaxResult;
    }

    public static AjaxResult ok(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",200);
        ajaxResult.put("data",data);
        return ajaxResult;
    }

    public static AjaxResult ok(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("code",200);
        return ajaxResult;
    }
}
